package com.book.controller;

import com.book.service.DataService;
import com.book.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author yicheng
 */
@RestController
@RequestMapping("/data")
public class DataController {
    @Autowired
    private DataService dataService;

    //按照月份和年份来统计销售金额
    @GetMapping("/getPriceByMonth")
    public ResponseResult getPriceByMonth(@RequestParam int year){
        return dataService.getPriceByMonth(year);
    }

    //按照季度来统计销售金额
    @GetMapping("/getPriceByQuarter")
    public ResponseResult getPriceByQuarter(@RequestParam int year){
        return dataService.getPriceByQuarter(year);
    }

    //相同年月统计销售数量前10的书籍，注意这里是两个参数
    @GetMapping("/getAmountSameDate")
    public ResponseResult getAmountSameDate(@RequestParam String year,@RequestParam String month){
        return dataService.getAmountSameDate(year,month);
    }

    //统计不同年月统计销售数量前10的书籍，注意这里有四个参数
    @GetMapping("/getAmountNoSameDate")
    public ResponseResult getAmountNoSameDate(@RequestParam String startYear, @RequestParam String startMonth,
                                              @RequestParam String endYear, @RequestParam String endMonth){
        return dataService.getAmountNoSameDate(startYear,startMonth,endYear,endMonth);
    }
}
